/*
 * =====================================================================================
 *
 *       Filename:  Random.h
 *
 *    Description:  随机数生成工具
 *
 *        Version:  1.0
 *        Created:  2011-10-29 11:03:24
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *        Company:  
 *
 * =====================================================================================
 */
#ifndef _Random_H_
#define _Random_H_

#include <ctime>

template <class T>
T averageRandom(T min, T max) {
    int minInteger = (int)(min*10000);
    int maxInteger = (int)(max*10000);
    int randInteger = rand()*rand();
    int diffInteger = maxInteger - minInteger;
    int resultInteger = randInteger % diffInteger + minInteger;
    return (T)(resultInteger/10000.0);
}

template <class T>
T easyRandom(T e) {
    return averageRandom(e, e);
}

#endif
